Skip to contentSkip to conversation

Change in openvpn[master]: Change hash values in our hash map from uint32_t to uint64_t

Openvpn-devel plaisthos (Code Review) 1 participant 6 messages Mar 11 – Mar 19 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): gerrit.1773251317000.Ib8140107f98164d2a2e1768a6d8ac65016cd7f7c@...2715...

#1 lore raw

plaisthos has uploaded this change for review. ( http://gerrit.openvpn.net/c/openvpn/+/1570?usp=email )

Change subject: Change hash values in our hash map from uint32_t to uint64_t
......................................................................

Change hash values in our hash map from uint32_t to uint64_t

32 bit architectures are playing a very small role today, so the difference between 64 bit and 32 bit hash values is not expected to be large anymore.

This is also in preparation to replace our hash function with a more modern replacement.

Change-Id Ib8140107f98164d2a2e1768a6d8ac65016cd7f7c

---
M src/openvpn/list.c
M src/openvpn/list.h
M src/openvpn/mroute.c
M src/openvpn/mroute.h
M src/openvpn/mtcp.c
M src/openvpn/mudp.c
M src/openvpn/multi.c
M tests/unit_tests/openvpn/test_misc.c

8 files changed, 30 insertions(+), 30 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/70/1570/1

src/openvpn/list.c +6 -6
index f0e9908..50defb85 100644
@@ -34,8 +34,8 @@
 #include "memdbg.h"
 
 struct hash *
-hash_init(const uint32_t n_buckets, const uint32_t iv,
-          uint32_t (*hash_function)(const void *key, uint32_t iv),
+hash_init(const uint32_t n_buckets, uint32_t iv,
+          uint64_t (*hash_function)(const void *key, uint32_t iv),
           bool (*compare_function)(const void *key1, const void *key2))
 {
     struct hash *h;
@@ -76,7 +76,7 @@
 }
 
 struct hash_element *
-hash_lookup_fast(struct hash *hash, struct hash_bucket *bucket, const void *key, uint32_t hv)
+hash_lookup_fast(struct hash *hash, struct hash_bucket *bucket, const void *key, uint64_t hv)
 {
     struct hash_element *he;
     struct hash_element *prev = NULL;
@@ -104,7 +104,7 @@
 }
 
 bool
-hash_remove_fast(struct hash *hash, struct hash_bucket *bucket, const void *key, uint32_t hv)
+hash_remove_fast(struct hash *hash, struct hash_bucket *bucket, const void *key, uint64_t hv)
 {
     struct hash_element *he;
     struct hash_element *prev = NULL;
@@ -136,7 +136,7 @@
 bool
 hash_add(struct hash *hash, const void *key, void *value, bool replace)
 {
-    uint32_t hv;
+    uint64_t hv;
     struct hash_bucket *bucket;
     struct hash_element *he;
     bool ret = false;
@@ -412,7 +412,7 @@
         c ^= (b >> 15); \
     }
 
-uint32_t
+uint64_t
 hash_func(const uint8_t *k, uint32_t length, uint32_t initval)
 {
     uint32_t a, b, c, len;
src/openvpn/list.h +11 -11
index 04cc3ab..06377c6 100644
@@ -40,7 +40,7 @@
 {
     void *value;
     const void *key;
-    uint32_t hash_value;
+    uint64_t hash_value;
     struct hash_element *next;
 };
 
@@ -55,13 +55,13 @@
     uint32_t n_elements;
     uint32_t mask;
     uint32_t iv;
-    uint32_t (*hash_function)(const void *key, uint32_t iv);
+    uint64_t (*hash_function)(const void *key, uint32_t iv);
     bool (*compare_function)(const void *key1, const void *key2); /* return true if equal */
     struct hash_bucket *buckets;
 };
 
 struct hash *hash_init(const uint32_t n_buckets, const uint32_t iv,
-                       uint32_t (*hash_function)(const void *key, uint32_t iv),
+                       uint64_t (*hash_function)(const void *key, uint32_t iv),
                        bool (*compare_function)(const void *key1, const void *key2));
 
 void hash_free(struct hash *hash);
@@ -69,9 +69,9 @@
 bool hash_add(struct hash *hash, const void *key, void *value, bool replace);
 
 struct hash_element *hash_lookup_fast(struct hash *hash, struct hash_bucket *bucket,
-                                      const void *key, uint32_t hv);
+                                      const void *key, uint64_t hv);
 
-bool hash_remove_fast(struct hash *hash, struct hash_bucket *bucket, const void *key, uint32_t hv);
+bool hash_remove_fast(struct hash *hash, struct hash_bucket *bucket, const void *key, uint64_t hv);
 
 void hash_remove_by_value(struct hash *hash, void *value);
 
@@ -98,9 +98,9 @@
 
 void hash_iterator_free(struct hash_iterator *hi);
 
-uint32_t hash_func(const uint8_t *k, uint32_t length, uint32_t initval);
+uint64_t hash_func(const uint8_t *k, uint32_t length, uint32_t initval);
 
-static inline uint32_t
+static inline uint64_t
 hash_value(const struct hash *hash, const void *key)
 {
     return (*hash->hash_function)(key, hash->iv);
@@ -119,7 +119,7 @@
 }
 
 static inline struct hash_bucket *
-hash_bucket(struct hash *hash, uint32_t hv)
+hash_bucket(struct hash *hash, uint64_t hv)
 {
     return &hash->buckets[hv & hash->mask];
 }
@@ -129,7 +129,7 @@
 {
     void *ret = NULL;
     struct hash_element *he;
-    uint32_t hv = hash_value(hash, key);
+    uint64_t hv = hash_value(hash, key);
     struct hash_bucket *bucket = &hash->buckets[hv & hash->mask];
 
     he = hash_lookup_fast(hash, bucket, key, hv);
@@ -143,7 +143,7 @@
 
 /* NOTE: assumes that key is not a duplicate */
 static inline void
-hash_add_fast(struct hash *hash, struct hash_bucket *bucket, const void *key, uint32_t hv,
+hash_add_fast(struct hash *hash, struct hash_bucket *bucket, const void *key, uint64_t hv,
               void *value)
 {
     struct hash_element *he;
@@ -160,7 +160,7 @@
 static inline bool
 hash_remove(struct hash *hash, const void *key)
 {
-    uint32_t hv;
+    uint64_t hv;
     struct hash_bucket *bucket;
     bool ret;
 
src/openvpn/mroute.c +1 -1
index 6fa70a3..78c689e 100644
@@ -354,7 +354,7 @@
  * address type, number of bits in the network address,
  * and the actual address.
  */
-uint32_t
+uint64_t
 mroute_addr_hash_function(const void *key, uint32_t iv)
 {
     return hash_func(mroute_addr_hash_ptr((const struct mroute_addr *)key),
src/openvpn/mroute.h +1 -1
index c8daa15..2f5d019 100644
@@ -144,7 +144,7 @@
 
 bool mroute_learnable_address(const struct mroute_addr *addr, struct gc_arena *gc);
 
-uint32_t mroute_addr_hash_function(const void *key, uint32_t iv);
+uint64_t mroute_addr_hash_function(const void *key, uint32_t iv);
 
 bool mroute_addr_compare_function(const void *key1, const void *key2);
 
src/openvpn/mtcp.c +1 -1
index b7bef46..5583d1c 100644
@@ -57,7 +57,7 @@
     {
         mi->real.proto = sock->info.proto;
         struct hash_element *he;
-        const uint32_t hv = hash_value(hash, &mi->real);
+        const uint64_t hv = hash_value(hash, &mi->real);
         struct hash_bucket *bucket = hash_bucket(hash, hv);
 
         multi_assign_peer_id(m, mi);
src/openvpn/mudp.c +1 -1
index b359750..c272f79 100644
@@ -204,7 +204,7 @@
     if (mroute_extract_openvpn_sockaddr(&real, &m->top.c2.from.dest, true) && m->top.c2.buf.len > 0)
     {
         struct hash_element *he;
-        const uint32_t hv = hash_value(hash, &real);
+        const uint64_t hv = hash_value(hash, &real);
         struct hash_bucket *bucket = hash_bucket(hash, hv);
         uint8_t *ptr = BPTR(&m->top.c2.buf);
         uint8_t op = ptr[0] >> P_OPCODE_SHIFT;
src/openvpn/multi.c +6 -6
index c03e821..57ea3fb 100644
@@ -228,11 +228,11 @@
 
 #ifdef ENABLE_MANAGEMENT
 
-static uint32_t
+static uint64_t
 cid_hash_function(const void *key, uint32_t iv)
 {
     const unsigned long *k = (const unsigned long *)key;
-    return (uint32_t)*k;
+    return (uint64_t)*k;
 }
 
 static bool
@@ -246,7 +246,7 @@
 #endif
 
 #ifdef ENABLE_ASYNC_PUSH
-static uint32_t
+static uint64_t
 /*
  * inotify watcher descriptors are used as hash value
  */
@@ -1021,7 +1021,7 @@
                  const unsigned int flags)
 {
     struct hash_element *he;
-    const uint32_t hv = hash_value(m->vhash, addr);
+    const uint64_t hv = hash_value(m->vhash, addr);
     struct hash_bucket *bucket = hash_bucket(m->vhash, hv);
     struct multi_route *oldroute = NULL;
     struct multi_instance *owner = NULL;
@@ -3103,7 +3103,7 @@
         goto done;
     }
 
-    const uint32_t hv = hash_value(hash, &real);
+    const uint64_t hv = hash_value(hash, &real);
     struct hash_bucket *bucket = hash_bucket(hash, hv);
 
     /* make sure that we don't float to an address taken by another client */
@@ -4247,7 +4247,7 @@
 multi_unlearn_addr(struct multi_context *m, struct multi_instance *mi, const struct mroute_addr *addr)
 {
     struct hash_element *he;
-    const uint32_t hv = hash_value(m->vhash, addr);
+    const uint64_t hv = hash_value(m->vhash, addr);
     struct hash_bucket *bucket = hash_bucket(m->vhash, hv);
     struct multi_route *r = NULL;
 
tests/unit_tests/openvpn/test_misc.c +3 -3
index a9ae33f..a8383de 100644
@@ -124,7 +124,7 @@
 };
 
 
-static uint32_t
+static uint64_t
 word_hash_function(const void *key, uint32_t iv)
 {
     const char *str = (const char *)key;
@@ -173,8 +173,8 @@
      */
 
     struct gc_arena gc = gc_new();
-    struct hash *hash = hash_init(10000, get_random(), word_hash_function, word_compare_function);
-    struct hash *nhash = hash_init(256, get_random(), word_hash_function, word_compare_function);
+    struct hash *hash = hash_init(10000, (uint32_t)get_random(), word_hash_function, word_compare_function);
+    struct hash *nhash = hash_init(256, (uint32_t)get_random(), word_hash_function, word_compare_function);
 
     printf("hash_init n_buckets=%u mask=0x%08x\n", hash->n_buckets, hash->mask);
 

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1570?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ib8140107f98164d2a2e1768a6d8ac65016cd7f7c
Gerrit-Change-Number: 1570
Gerrit-PatchSet: 1
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>

#2 lore raw
In reply to a message not in the archive

Attention is currently required from: plaisthos.

flichtenheld has posted comments on this change by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/1570?usp=email )

Change subject: Change hash values in our hash map from uint32_t to uint64_t
......................................................................

Patch Set 2: Code-Review-1

(1 comment)

File src/openvpn/multi.c:

http://gerrit.openvpn.net/c/openvpn/+/1570/comment/1f666d5a_d31b9d89?usp=email :
PS2, Line 255: return (uint32_t)(uintptr_t)key;
Why not remove the uint32_t cast here?

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1570?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ib8140107f98164d2a2e1768a6d8ac65016cd7f7c
Gerrit-Change-Number: 1570
Gerrit-PatchSet: 2
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Comment-Date: Thu, 12 Mar 2026 11:27:48 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes

#3 lore raw
In reply to a message not in the archive

Attention is currently required from: plaisthos.

flichtenheld has posted comments on this change by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/1570?usp=email )

Change subject: Change hash values in our hash map from uint32_t to uint64_t
......................................................................

Patch Set 2:

(1 comment)

File tests/unit_tests/openvpn/test_misc.c:

http://gerrit.openvpn.net/c/openvpn/+/1570/comment/e9ce02ce_c816e1a1?usp=email :
PS2, Line 176: struct hash *hash = hash_init(10000, (uint32_t)get_random(), word_hash_function, word_compare_function);
get_random already returns uint32_t, so this is a meaningless cast.

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1570?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ib8140107f98164d2a2e1768a6d8ac65016cd7f7c
Gerrit-Change-Number: 1570
Gerrit-PatchSet: 2
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Comment-Date: Thu, 12 Mar 2026 11:35:24 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No

#4 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld.

plaisthos has posted comments on this change by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/1570?usp=email )

Change subject: Change hash values in our hash map from uint32_t to uint64_t
......................................................................

Patch Set 3:

(1 comment)

File tests/unit_tests/openvpn/test_misc.c:

http://gerrit.openvpn.net/c/openvpn/+/1570/comment/71b58226_c5cd5e8a?usp=email :
PS2, Line 176: struct hash *hash = hash_init(10000, (uint32_t)get_random(), word_hash_function, word_compare_function);

Quoted 1 line

get_random already returns uint32_t, so this is a meaningless cast.

Done

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1570?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ib8140107f98164d2a2e1768a6d8ac65016cd7f7c
Gerrit-Change-Number: 1570
Gerrit-PatchSet: 3
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Thu, 19 Mar 2026 12:58:29 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: flichtenheld <[email protected]...>

#5 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld.

plaisthos has posted comments on this change by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/1570?usp=email )

Change subject: Change hash values in our hash map from uint32_t to uint64_t
......................................................................

Patch Set 3:

(1 comment)

File src/openvpn/multi.c:

http://gerrit.openvpn.net/c/openvpn/+/1570/comment/301d83f2_79ac416f?usp=email :
PS2, Line 255: return (uint32_t)(uintptr_t)key;

Quoted 1 line

Why not remove the uint32_t cast here?

Acknowledged

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1570?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ib8140107f98164d2a2e1768a6d8ac65016cd7f7c
Gerrit-Change-Number: 1570
Gerrit-PatchSet: 3
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Thu, 19 Mar 2026 13:06:49 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: flichtenheld <[email protected]...>

#6 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld.

Hello flichtenheld,

I'd like you to reexamine a change. Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1570?usp=email

to look at the new patch set (#4).

The following approvals got outdated and were removed:
Code-Review-1 by flichtenheld

Change subject: Change hash values in our hash map from uint32_t to uint64_t
......................................................................

Change hash values in our hash map from uint32_t to uint64_t

32 bit architectures are playing a very small role today, so the difference between 64 bit and 32 bit hash values is not expected to be large anymore.

This is also in preparation to replace our hash function with a more modern replacement.

Change-Id Ib8140107f98164d2a2e1768a6d8ac65016cd7f7c

---
M src/openvpn/list.c
M src/openvpn/list.h
M src/openvpn/mroute.c
M src/openvpn/mroute.h
M src/openvpn/mtcp.c
M src/openvpn/mudp.c
M src/openvpn/multi.c
M tests/unit_tests/openvpn/test_misc.c

8 files changed, 30 insertions(+), 30 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/70/1570/4

src/openvpn/list.c +6 -6
index f0e9908..50defb85 100644
@@ -34,8 +34,8 @@
 #include "memdbg.h"
 
 struct hash *
-hash_init(const uint32_t n_buckets, const uint32_t iv,
-          uint32_t (*hash_function)(const void *key, uint32_t iv),
+hash_init(const uint32_t n_buckets, uint32_t iv,
+          uint64_t (*hash_function)(const void *key, uint32_t iv),
           bool (*compare_function)(const void *key1, const void *key2))
 {
     struct hash *h;
@@ -76,7 +76,7 @@
 }
 
 struct hash_element *
-hash_lookup_fast(struct hash *hash, struct hash_bucket *bucket, const void *key, uint32_t hv)
+hash_lookup_fast(struct hash *hash, struct hash_bucket *bucket, const void *key, uint64_t hv)
 {
     struct hash_element *he;
     struct hash_element *prev = NULL;
@@ -104,7 +104,7 @@
 }
 
 bool
-hash_remove_fast(struct hash *hash, struct hash_bucket *bucket, const void *key, uint32_t hv)
+hash_remove_fast(struct hash *hash, struct hash_bucket *bucket, const void *key, uint64_t hv)
 {
     struct hash_element *he;
     struct hash_element *prev = NULL;
@@ -136,7 +136,7 @@
 bool
 hash_add(struct hash *hash, const void *key, void *value, bool replace)
 {
-    uint32_t hv;
+    uint64_t hv;
     struct hash_bucket *bucket;
     struct hash_element *he;
     bool ret = false;
@@ -412,7 +412,7 @@
         c ^= (b >> 15); \
     }
 
-uint32_t
+uint64_t
 hash_func(const uint8_t *k, uint32_t length, uint32_t initval)
 {
     uint32_t a, b, c, len;
src/openvpn/list.h +11 -11
index 04cc3ab..06377c6 100644
@@ -40,7 +40,7 @@
 {
     void *value;
     const void *key;
-    uint32_t hash_value;
+    uint64_t hash_value;
     struct hash_element *next;
 };
 
@@ -55,13 +55,13 @@
     uint32_t n_elements;
     uint32_t mask;
     uint32_t iv;
-    uint32_t (*hash_function)(const void *key, uint32_t iv);
+    uint64_t (*hash_function)(const void *key, uint32_t iv);
     bool (*compare_function)(const void *key1, const void *key2); /* return true if equal */
     struct hash_bucket *buckets;
 };
 
 struct hash *hash_init(const uint32_t n_buckets, const uint32_t iv,
-                       uint32_t (*hash_function)(const void *key, uint32_t iv),
+                       uint64_t (*hash_function)(const void *key, uint32_t iv),
                        bool (*compare_function)(const void *key1, const void *key2));
 
 void hash_free(struct hash *hash);
@@ -69,9 +69,9 @@
 bool hash_add(struct hash *hash, const void *key, void *value, bool replace);
 
 struct hash_element *hash_lookup_fast(struct hash *hash, struct hash_bucket *bucket,
-                                      const void *key, uint32_t hv);
+                                      const void *key, uint64_t hv);
 
-bool hash_remove_fast(struct hash *hash, struct hash_bucket *bucket, const void *key, uint32_t hv);
+bool hash_remove_fast(struct hash *hash, struct hash_bucket *bucket, const void *key, uint64_t hv);
 
 void hash_remove_by_value(struct hash *hash, void *value);
 
@@ -98,9 +98,9 @@
 
 void hash_iterator_free(struct hash_iterator *hi);
 
-uint32_t hash_func(const uint8_t *k, uint32_t length, uint32_t initval);
+uint64_t hash_func(const uint8_t *k, uint32_t length, uint32_t initval);
 
-static inline uint32_t
+static inline uint64_t
 hash_value(const struct hash *hash, const void *key)
 {
     return (*hash->hash_function)(key, hash->iv);
@@ -119,7 +119,7 @@
 }
 
 static inline struct hash_bucket *
-hash_bucket(struct hash *hash, uint32_t hv)
+hash_bucket(struct hash *hash, uint64_t hv)
 {
     return &hash->buckets[hv & hash->mask];
 }
@@ -129,7 +129,7 @@
 {
     void *ret = NULL;
     struct hash_element *he;
-    uint32_t hv = hash_value(hash, key);
+    uint64_t hv = hash_value(hash, key);
     struct hash_bucket *bucket = &hash->buckets[hv & hash->mask];
 
     he = hash_lookup_fast(hash, bucket, key, hv);
@@ -143,7 +143,7 @@
 
 /* NOTE: assumes that key is not a duplicate */
 static inline void
-hash_add_fast(struct hash *hash, struct hash_bucket *bucket, const void *key, uint32_t hv,
+hash_add_fast(struct hash *hash, struct hash_bucket *bucket, const void *key, uint64_t hv,
               void *value)
 {
     struct hash_element *he;
@@ -160,7 +160,7 @@
 static inline bool
 hash_remove(struct hash *hash, const void *key)
 {
-    uint32_t hv;
+    uint64_t hv;
     struct hash_bucket *bucket;
     bool ret;
 
src/openvpn/mroute.c +1 -1
index 6fa70a3..78c689e 100644
@@ -354,7 +354,7 @@
  * address type, number of bits in the network address,
  * and the actual address.
  */
-uint32_t
+uint64_t
 mroute_addr_hash_function(const void *key, uint32_t iv)
 {
     return hash_func(mroute_addr_hash_ptr((const struct mroute_addr *)key),
src/openvpn/mroute.h +1 -1
index c8daa15..2f5d019 100644
@@ -144,7 +144,7 @@
 
 bool mroute_learnable_address(const struct mroute_addr *addr, struct gc_arena *gc);
 
-uint32_t mroute_addr_hash_function(const void *key, uint32_t iv);
+uint64_t mroute_addr_hash_function(const void *key, uint32_t iv);
 
 bool mroute_addr_compare_function(const void *key1, const void *key2);
 
src/openvpn/mtcp.c +1 -1
index b7bef46..5583d1c 100644
@@ -57,7 +57,7 @@
     {
         mi->real.proto = sock->info.proto;
         struct hash_element *he;
-        const uint32_t hv = hash_value(hash, &mi->real);
+        const uint64_t hv = hash_value(hash, &mi->real);
         struct hash_bucket *bucket = hash_bucket(hash, hv);
 
         multi_assign_peer_id(m, mi);
src/openvpn/mudp.c +1 -1
index b359750..c272f79 100644
@@ -204,7 +204,7 @@
     if (mroute_extract_openvpn_sockaddr(&real, &m->top.c2.from.dest, true) && m->top.c2.buf.len > 0)
     {
         struct hash_element *he;
-        const uint32_t hv = hash_value(hash, &real);
+        const uint64_t hv = hash_value(hash, &real);
         struct hash_bucket *bucket = hash_bucket(hash, hv);
         uint8_t *ptr = BPTR(&m->top.c2.buf);
         uint8_t op = ptr[0] >> P_OPCODE_SHIFT;
src/openvpn/multi.c +8 -8
index c03e821..01d7e9d 100644
@@ -228,11 +228,11 @@
 
 #ifdef ENABLE_MANAGEMENT
 
-static uint32_t
+static uint64_t
 cid_hash_function(const void *key, uint32_t iv)
 {
     const unsigned long *k = (const unsigned long *)key;
-    return (uint32_t)*k;
+    return (uint64_t)*k;
 }
 
 static bool
@@ -246,19 +246,19 @@
 #endif
 
 #ifdef ENABLE_ASYNC_PUSH
-static uint32_t
+static uint64_t
 /*
  * inotify watcher descriptors are used as hash value
  */
 int_hash_function(const void *key, uint32_t iv)
 {
-    return (uint32_t)(uintptr_t)key;
+    return (uintptr_t)key;
 }
 
 static bool
 int_compare_function(const void *key1, const void *key2)
 {
-    return (unsigned long)key1 == (unsigned long)key2;
+    return (uintptr_t)key1 == (uintptr_t)key2;
 }
 #endif
 
@@ -1021,7 +1021,7 @@
                  const unsigned int flags)
 {
     struct hash_element *he;
-    const uint32_t hv = hash_value(m->vhash, addr);
+    const uint64_t hv = hash_value(m->vhash, addr);
     struct hash_bucket *bucket = hash_bucket(m->vhash, hv);
     struct multi_route *oldroute = NULL;
     struct multi_instance *owner = NULL;
@@ -3103,7 +3103,7 @@
         goto done;
     }
 
-    const uint32_t hv = hash_value(hash, &real);
+    const uint64_t hv = hash_value(hash, &real);
     struct hash_bucket *bucket = hash_bucket(hash, hv);
 
     /* make sure that we don't float to an address taken by another client */
@@ -4247,7 +4247,7 @@
 multi_unlearn_addr(struct multi_context *m, struct multi_instance *mi, const struct mroute_addr *addr)
 {
     struct hash_element *he;
-    const uint32_t hv = hash_value(m->vhash, addr);
+    const uint64_t hv = hash_value(m->vhash, addr);
     struct hash_bucket *bucket = hash_bucket(m->vhash, hv);
     struct multi_route *r = NULL;
 
tests/unit_tests/openvpn/test_misc.c +1 -1
index a9ae33f..ccdfdee 100644
@@ -124,7 +124,7 @@
 };
 
 
-static uint32_t
+static uint64_t
 word_hash_function(const void *key, uint32_t iv)
 {
     const char *str = (const char *)key;

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1570?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ib8140107f98164d2a2e1768a6d8ac65016cd7f7c
Gerrit-Change-Number: 1570
Gerrit-PatchSet: 4
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>